package com.agriculture.data_demo.controller.api;

import com.agriculture.data_demo.dto.PageResult;
import com.agriculture.data_demo.dto.Result;
import com.agriculture.data_demo.service.HenService;
import com.agriculture.data_demo.vo.sys.HenBatchVo;
import com.agriculture.data_demo.vo.sys.HenDailyVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@ApiModel(value = "蛋鸡数据Controller")
@Slf4j
@RestController
public class HenController {

    @Resource
    private HenService henService;

    @ApiOperation(value = "查询所有蛋鸡批次数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber", value = "页码"),
            @ApiImplicitParam(name = "pageSize", value = "页大小")
    })
    @GetMapping(value = "/hen_batch")
    public ResponseEntity<HenBatchVo> getAllHenBatch(@RequestParam(value = "pageNumber",
    defaultValue = "0") Integer pageNumber, @RequestParam(value = "pageSize", defaultValue = "15")
    Integer pageSize){
        return new ResponseEntity(new Result<PageResult<HenBatchVo>>().ok("success",
                henService.getAllHenBatch(pageNumber, pageSize)), HttpStatus.OK);
    }

    @ApiOperation(value = "查询所有蛋鸡生产周期数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber", value = "页码"),
            @ApiImplicitParam(name = "pageSize", value = "页大小")
    })
    @GetMapping(value = "/hen_daily")
    public ResponseEntity<HenDailyVo> getAllHenDaily(@RequestParam(value = "pageNumber",
            defaultValue = "0") Integer pageNumber, @RequestParam(value = "pageSize", defaultValue = "15")
            Integer pageSize){
        return new ResponseEntity(new Result<PageResult<HenDailyVo>>().ok("success",
                henService.getAllHenDaily(pageNumber, pageSize)), HttpStatus.OK);
    }
}
